package com.aolei.mallshop.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class OrderConfirmVo {

    //收货地址
    @Getter @Setter
    List<MemberAddressVo> address;

    //购物项
    @Getter @Setter
    List<OrderItemVo> items;

    //优惠劵
    @Getter @Setter
    Integer integration;

    @Getter @Setter
    Map<Long,Boolean> stocks;

    public Integer getCount(){
        Integer i = 0;
        if (items!=null){
            for (OrderItemVo item : items){
                i+=item.getCount();
            }
        }
        return i;
    }

    //总价格
    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (items!=null){
            for (OrderItemVo item : items){
                sum=sum.add(item.getTotalPrice());
            }
        }
        return sum;
    }

    //优惠后
//    BigDecimal payPrice;

    public BigDecimal getPayPrice() {
        return getTotal();
    }

    //防重令牌
    @Getter @Setter
    String orderToken;
}
